Skip to content

MLEBABecLap aniso 2D and 3D#5216

Open
eebasso wants to merge 2 commits intoAMReX-Codes:developmentfrom
eebasso:mlebabeclap-aniso-eb-fluxes
Open

MLEBABecLap aniso 2D and 3D#5216
eebasso wants to merge 2 commits intoAMReX-Codes:developmentfrom
eebasso:mlebabeclap-aniso-eb-fluxes

Conversation

@eebasso
Copy link
Copy Markdown
Contributor

@eebasso eebasso commented Mar 21, 2026

Summary

Changes in MLEBABecLap for 3D and 2D to way flux is computed for EB surfaces.

The goal is removing the assumption that dx=dy=dz (anisotropic cells).

Additional background

The changes concern the way how Feb is computed. The changes in #2640 were only for 2D. This handles both 2D and 3D, with 2D changed to be more consistent with 3D.

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

@WeiqunZhang
Copy link
Copy Markdown
Member

I only checked changes in 2D mlebabeclap_adotx_centroid. It does not seem correct to me. The grad_eb_of_phi_on_centroids_extdir function uses anrmx and anrmy as follows:

Real dphidn = rhs(1)*nrmx + rhs(2)*nrmy;
return dphidn;

If the return value is scaled by a constant, it can be re-scaled later. But in your change, the ratio of nrmx to nrmy has changed. So I don't see how that can be correct.

@eebasso
Copy link
Copy Markdown
Contributor Author

eebasso commented Mar 26, 2026

In grad_eb_of_phi_on_centroids_extdir, rhs is the difference in phi in the x and y directions, but it has not been divided by a physical dx quantity yet. In other words, I am treating rhs and the output of grad_eb_of_phi_on_centroids_extdir as

rhs(1) = $\Delta_{x} \phi$ = dx $\frac{\partial\phi}{\partial x}$
rhs(2) = $\Delta_{y} \phi$ = dy $\frac{\partial\phi}{\partial y}$
grad_eb_of_phi_on_centroids_extdir = nrmx * dx * $\frac{\partial\phi}{\partial x}$ + nrmy * dy * $\frac{\partial\phi}{\partial y}$

This is why I scaled anrmx and anrmy the way I did. With anrmx = (apxm - apxp) dhx and anrmy = (apym - apyp) dhy, feb evaluates to

feb = beb * ( (apxm - apxp) dhx dx $\frac{\partial\phi}{\partial x}$ + (apym - apyp) dhy dy $\frac{\partial\phi}{\partial y}$ )

Apply definitions of dhx and dhy:

feb = B * beb * ( $\frac{\mathrm{apxm} - \mathrm{apxp}}{\mathrm{dx}}$ $\frac{\partial\phi}{\partial x}$ + $\frac{\mathrm{apym} - \mathrm{apyp}}{\mathrm{dy}}$ $\frac{\partial\phi}{\partial y}$)

@WeiqunZhang
Copy link
Copy Markdown
Member

This handles both 2D and 3D, with 2D changed to be more consistent with 3D.

So the proposed change in 2D is not just more consistency, right?

@eebasso
Copy link
Copy Markdown
Contributor Author

eebasso commented Mar 26, 2026

Yes, I think you are right, it's more than just consistency. The extra dxi factor is necessary to actually get spatial derivatives. This effect only matters when dx =/= dy. My apologizes for not adding a test to this PR. I can convert to draft if that's more appropriate.

@WeiqunZhang
Copy link
Copy Markdown
Member

No problems. I thought the 2D was just a programming style change and I was focusing on whether the 2D behavior has changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants